[#if adspace?? && adspace.enabled]
(function() {
var Ad = function(iId,sHtml,fCode,dStart,dEnd,iWeight) {
	this.iId = iId;
	this.sHtml = sHtml;
	this.fCode = fCode;
	this.dStart = dStart;
	this.dEnd = dEnd;
	this.iWeight = iWeight;
}
var ads = new Array(${adList?size});
var adsLen = 0;
[#list adList as ad]
[#if ad.category=="image"]
[#assign html]
<a href="${(ad.attr.image_link)!}" target="${ad.attr.image_target!}" title="${(ad.attr.image_title)!}" onclick="$.get('${base}/ad_click.jspx?id=${ad.id}');">
<img src="${ad.attr.image_url}" border="0"[#if (ad.attr.image_width)??] width="${ad.attr.image_width}"[/#if][#if (ad.attr.image_height)??] height="${ad.attr.image_height}"[/#if]/>
</a>
[/#assign]
ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null,
	[#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if],
	[#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if],
	${ad.weight});

[#elseif ad.category=="flash"]
[#assign html]
<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" menu="true"
 src="${(ad.attr.flash_url)!}"[#if ad.attr.flash_width?? && ad.attr.flash_width!=""] width="${ad.attr.flash_width}"[/#if][#if ad.attr.flash_height?? && ad.attr.flash_height!=""] height="${ad.attr.flash_height}"[/#if]></embed>
[/#assign]
ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null,
	[#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if],
	[#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if],
	${ad.weight});

[#elseif ad.category=="text"]
[#assign html]
<a href="${(ad.attr.text_link)!}" target="${(ad.attr.text_target)!}" onclick="$.get('${base}/ad_click.jspx?id=${ad.id}');">
	<span style="[#if (ad.attr.text_color)??]color:${ad.attr.text_color};[/#if][#if (ad.attr.text_font)??]font-size:${ad.attr.text_font};[/#if]">${(ad.attr.text_title)!}</span>
</a>
[/#assign]
ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null,
	[#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if],
	[#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if],
	${ad.weight});

[#elseif ad.category=="code"]
ads[adsLen++] = new Ad(${ad.id},null,function(){${ad.code!}},
	[#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if],
	[#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if],
	${ad.weight});

[#else]
document.write("未知的广告类型：${ad.category!}");
[/#if]
[/#list]
var indexArr = new Array();
var now = new Date();
for(var i=0,j=0,len=ads.length;i<len;i++){
	if((!ads[i].dStart || now>ads[i].dStart) && (!ads[i].dEnd || now<ads[i].dEnd)) {
		for(var max=j+ads[i].iWeight;j<max;j++) {
			indexArr[j] = i;
		}
	}
}

var rand = parseInt(Math.random() * indexArr.length);
var show = ads[indexArr[rand]];
if(show.sHtml) {
	document.write(show.sHtml);
} else {
	show.fCode();
}
$.get("${base}/ad_display.jspx?id="+show.iId);
})();
[#else]
广告版位不存在
[/#if]